package com.example.app_emu.device

import android.util.Log
import com.example.app_emu.core.EmulatorDevice
import com.example.app_emu.core.IEmulatorContext
import com.example.app_emu.core.control.DebugRPC
import com.example.lib_core.util.BufferConverter
import com.example.lib_core.util.JsonUtils
import com.example.session.IEndPoint

class MyEmulatorDevice(context: IEmulatorContext, profile: Profile) : EmulatorDevice(context, profile) {

    override fun init() {

    }

    override fun onReceived(payload: ByteArray, endpoint: IEndPoint) {
        //todo 协议解析
    }

    override fun onRPC(rpc: DebugRPC) {
        when(rpc.method){
            "set_device_name" -> {
                val name = rpc.params["name"]!!.toString()
                this.profile.name = name
            }
            "get_device_name" -> {
                val rpc = DebugRPC()
                rpc.method ="get_device_name"
                rpc.params["name"] = profile.name
                rpc.target = profile.sn
                responseRPC(rpc)
            }
        }
    }

}